import java.util.Scanner;
import java.util.Random;
public class ChangeAndType {
    public static void main(String[] args) {
        // 生成1-100的随机数
        Random random = new Random();
        int targetNumber = random.nextInt(100) + 1;

        Scanner scanner = new Scanner(System.in);

        System.out.println("欢迎来到猜数字游戏！请输入1-100之间的整数：");

        while(true) {
            System.out.print("请输入你的猜测：");
            int userGuess = scanner.nextInt();

            if(userGuess > targetNumber) {
                System.out.println("太大了！");
            } else if(userGuess < targetNumber) {
                System.out.println("太小了！");
            } else {
                System.out.println("恭喜你，猜对了！正确答案是：" + targetNumber);
                break; // 退出循环
            }
        }

        scanner.close();
    }
}
